package net.ddns.xcyyds.kungfu.procedures;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.event.CommandEvent;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.entity.Entity;

import net.ddns.xcyyds.kungfu.network.KungFuModVariables;
import net.ddns.xcyyds.kungfu.init.KungFuModGameRules;

import javax.annotation.Nullable;

@Mod.EventBusSubscriber
public class NeiLiDamageUseProcedure {
	@SubscribeEvent
	public static void onCommand(CommandEvent event) {
		Entity entity = event.getParseResults().getContext().getSource().getEntity();
		if (entity != null) {
			execute(event, entity.level);
		}
	}

	public static void execute(LevelAccessor world) {
		execute(null, world);
	}

	private static void execute(@Nullable Event event, LevelAccessor world) {
		KungFuModVariables.MapVariables.get(world).neiLiMul = (world.getLevelData().getGameRules().getInt(KungFuModGameRules.NEILIDAMAGE)) * 0.01;
		KungFuModVariables.MapVariables.get(world).syncData(world);
	}
}
